<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="../libs/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="../libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="../libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
  <div id="demo1"></div>
  <div id="demo2"></div>
  <div id="demo3"></div>
  <div id="demo4"></div>
  <script>
    a = 1;
    b = 2;
    c = a + b;
    document.getElementById("demo1").innerHTML = 100*c + "w";
    x = 1; y = 2; z = x + y;
    document.getElementById("demo2").innerHTML = 200*z + "吗" + "他到底有多少秘密我不知道的";
    document.getElementById("demo3").innerHTML = 200 + z + c;
  </script>
  <script>
    var x1=34.00;
    var x2=34;
    var y=123e5;
    var z=123e-5;
    document.write("<div>");
    document.write(x1 + "<br>");
    document.write(x2 + "<br>");
    document.write(y + "<br>");
    document.write(z + "<br>");
    document.write("</div>");

  </script>
  <script>
    var a1 = "西安高新区";
    var b1 = 1;
    var c1 = 0.1234;
    var d1 = false;
    var d2 = true;
    var array1 = ["array0", "array1","array2"];

    var cities = new Array();
    cities[0] = "北京";
    document.getElementById("demo4").innerHTML = a1 + array1[0] + cities[0];
//
//    if (a1 == '北京') {
//      document.getElementById("demo4").innerHTML = document.getElementById("demo4").innerHTML + '首都';
//    } else {
//      document.getElementById("demo4").innerHTML = '首都';
//    }
//
//    for (var i = 0; i < array1.length; i++) {
//      document.getElementById("demo4").innerHTML = document.getElementById("demo4").innerHTML + array1[i];
//    }

    function jump() {
      if (a1 == '北京') {
        document.getElementById("demo4").innerHTML = document.getElementById("demo4").innerHTML + '首都';
      } else {
        document.getElementById("demo4").innerHTML = '首都';
      }

      for (var i = 0; i < array1.length; i++) {
        document.getElementById("demo4").innerHTML = document.getElementById("demo4").innerHTML + array1[i];
      }
    }
    function clear_divs() {
      $("div #demo1").each(function(){
        $(this).empty();
      });
    }
    function add_button() {
      $("body").append("<button>abc</button>");
    }

    function get_div_text() {
      var all_text = '';
      var counter = 0;
      $("div").each(function(){
        counter++;
        all_text += '\n' + counter + ': ' + $(this).text();
      });
      return all_text;
    }

  </script>

  <a onclick="jump(); return false;" class="btn btn-danger">执行jump();</a>
  <a onclick="clear_divs(); return false;" class="btn btn-danger">执行clear_divs();</a>
  <a onclick="add_button(); return false;" class="btn btn-danger">执行add_button();</a>
  <a onclick="console.log(get_div_text()); return false;" class="btn btn-danger">get_div_text();</a>
</body>
</html>